package com.yxx.service;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
 * Redis服务接口
 * @author yuxiangxun
 * @date 2025/1/19
 * @apiNote
 */
public interface RedisService {
    Boolean setExpire(String key, long timeout, TimeUnit timeUnit);


    Long getExpire(String key, TimeUnit timeUnit);


    Collection<String> getKeys(String pattern);

    Boolean hasKey(String key);


    <T> void setObject(String key, T value);


    <T> void setObject(String key, T value, long timeout, TimeUnit timeUnit);


    <T> T getObject(String key);


    Boolean deleteObject(String key);


    Long deleteObject(List<String> keys);


    Long incr(String key, long delta);


    Long decr(String key, long delta);


    <T> void setHash(String key, String hashKey, T value);


    <T> Boolean setHash(String key, String hashKey, T value, long timeout, TimeUnit timeUnit);


    <T> void setHashAll(String key, Map<String, T> map);


    <T> Boolean setHashAll(String key, Map<String, T> map, long timeout, TimeUnit timeUnit);


    <T> T getHash(String key, String hashKey);


    Map getHashAll(String key);


    <T> void deleteHash(String key, T... hashKeys);


    Boolean hasHashValue(String key, String hashKey);


    Long incrHash(String key, String hashKey, Long delta);


    Long decrHash(String key, String hashKey, Long delta);


    <T> Long setList(String key, T value);

    <T> Long setList(String key, T value, long timeout, TimeUnit timeUnit);


    <T> Long setListAll(String key, T... values);


    <T> Long setListAll(String key, long timeout, TimeUnit timeUnit, T... values);


    <T> List<T> getList(String key, long start, long end);


    <T> T getListByIndex(String key, long index);

    Long getListSize(String key);


    <T> Long deleteList(String key, long count, T value);


    <T> Long setSet(String key, T... values);

    <T> Long setSet(String key, long timeout, TimeUnit timeUnit, T... values);


    <T> Set<T> getSet(String key);


    <T> Long deleteSet(String key, T... values);


    <T> Boolean hasSetValue(String key, T value);


    Long getSetSize(String key);


    <T> Double incrZet(String key, T value, Double score);

    <T> Double decrZet(String key, T value, Double score);


    <T> Long deleteZetScore(String key, T... values);

    Map<Object, Double> zReverseRangeWithScore(String key, long start, long end);


    <T> Double getZsetScore(String key, T value);


    Map<Object, Double> getZsetAllScore(String key);
}
